<!doctype html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>设置</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/binge.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>

<body>
<div id="header" style="height: 0.9rem; background: #fff; position: fixed; top: 0;left: 0; width: 100%; z-index: 99">
    <header class="header header-shadow">
        <div class="header-left">
            <div tapmode onclick="comeBack();" class="nav-left"><img class="icon-back" src="../../icon/icon-back.png"/>
            </div>
        </div>
        <h2>设置</h2>
    </header>
</div>
<div class="header-h" style="padding-top: 1.5rem;"></div>
<section class="html_section pr30 pl30 setting_html">
    <ul class="setting_option f30">
        <li tapmode class="between line_center c-666" onclick="commonUrl('account')">
            <div>账号与安全</div>
            <img class="ml30 arr_move" src='../../icon/move.png'/>
        </li>
        <li tapmode class="between line_center c-666" onclick="commonUrl('fankui')">
            <div>反馈与客服</div>
            <img class="ml30 arr_move" src='../../icon/move.png'/>
        </li>
        <li tapmode class="between line_center c-666" id="encourage" style="display: none;" onclick="openModel()">
            <div>鼓励一下</div>
            <img class="ml30 arr_move" src='../../icon/move.png'/>
        </li>
        <li tapmode class="between line_center c-666" onclick="commonUrl('about')">
            <div>关于我们</div>
            <img class="ml30 arr_move" src='../../icon/move.png'/>
        </li>
        <li tapmode class="between line_center c-666" onclick="commonUrl('myShield')">
            <div>我的屏蔽</div>
            <img class="ml30 arr_move" src='../../icon/move.png'/>
        </li>
        <li tapmode class="between line_center c-666" onclick="qcChace()">
            <div>清除缓存</div>
            <div id="caCheSize" class="c-999 f24"></div>
        </li>
        <li tapmode class="between line_center c-666">
            <div>当前版本</div>
            <div class="c-999 f24" id="appVersion">1.0.1</div>
        </li>
    </ul>
    <div tapmode class="btn1 f30">退出登录</div>
</section>

<!-- 右上角操作 -->
<div class="action-model model" tapmode onclick="closeModel()">
    <div class="action-view" tapmode onclick="stopModel(event)">
        <h6 class="shareTitle1">鼓励一下</h6>
        <a href="javascript:void(0);" tapmode onclick="closeModel(event)" class="model-close"></a>
        <div class="model-detail">
            <ul id="encourageCon"></ul>

            <!--<ul id="encourageCon">
                &lt;!&ndash;<li tapmode onclick="shareWx(event)">
                    <div class="share-icon icon1"></div>
                    <p>微信</p>
                </li>
                <li tapmode onclick="shareWxq(event)">
                    <div class="share-icon icon2"></div>
                    <p>朋友圈</p>
                </li>
                <li tapmode onclick="shareQq(event)">
                    <div class="share-icon icon3"></div>
                    <p>QQ</p>
                </li>
                <li tapmode onclick="shareQzone(event)">
                    <div class="share-icon icon4"></div>
                    <p>QQ空间</p>
                </li>
                <li tapmode onclick="shareWb(event)">
                    <div class="share-icon icon5"></div>
                    <p>微博</p>
                </li>&ndash;&gt;
                &lt;!&ndash;<li tapmode class="copy" onclick="copyLink()">
                    <div class="share-icon icon-copy"></div>
                    <p>复制链接</p>
                </li>&ndash;&gt;
            </ul>-->
        </div>
        <!--<div class="shade-user">
            <a href="javascript:void(0);" class="shade-btn"><span>屏蔽此人</span></a>
        </div>-->
    </div>
</div>
<!-- 右上角操作 end -->
</body>

</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    var _model = $(".model");
    var _modelStatus = true;
    apiready = function () {
        setFixStatusBar(); //设置状态栏
        keybackListener()
        var appVersion = api.appVersion;//获取当前版本号
        $("#appVersion").html(appVersion)

        getCacheSize(function (size) {
            $("#caCheSize").html(size);
        })

        SystemCheckVersion();
        var phone = $api.getStorage('phone');
        console.log(phone);

        getEncourageList()

    }

    $(".btn1").click(function () {
        $api.setStorage('token', null);
        $api.setStorage('userInfo', null);
        $api.setStorage('schoolPath', null);
        // var winFrame = ['index','circle','school_index','match_index','member'];

        /*var wins = api.windows();
        $.each(wins,function (i,item) {
            console.log(item.name)
            if(item.name != 'login_pwd'){
                api.closeWin({
                    name: item.name,
                    animation:{
                        type: 'none'
                    }
                })
            }else {

            }
        });*/

        api.closeWin({
            name: 'member',
        })
        individualUrl('../login/login_pwd');

    })

    function getEncourageList() {
        console.log('鼓励一下')
        getAjax(Interface.encourage, '', function (res) {
            var data = res.data;
            console.log(jsonChange(res));
            var html = '';
            if (isDefine(data)) {
                _modelStatus = true;


                $.each(data, function (i, item) {
                   /* var p = {
                        myPackage: 'com.binge.wt',
                        package: item.package_name,
                    }
                    html = '<li tapmode onclick=\'encourage(event,' + jsonChange(p) + ')\'>\n' +
                        '                    <div class="share-icon bg-cover" style="background: url('+ajaxUrl+item.icon_path+') center no-repeat;"></div>\n' +
                        '                    <p>' + item.title + '</p>\n' +
                        '                </li>';
                    $("#encourageCon").append(html);*/

                    api.appInstalled({
                        appBundle: item.package_name,
                    }, function(ret, err) {
                        if (ret.installed) {
                            console.log(ret.installed)
                            //应用已安装
                            var p = {
                                myPackage: 'com.dxqbj.wt',
                                package: item.package_name,
                            }
                            html = '<li tapmode onclick=\'encourage(event,' + jsonChange(p) + ')\'>\n' +
                                '                    <div class="share-icon bg-cover" style="background: url('+ajaxUrl+item.icon_path+') center no-repeat;"></div>\n' +
                                '                    <p>' + item.title + '</p>\n' +
                                '                </li>';
                            $("#encourageCon").append(html);
                        } else {
                            //应用未安装
                            console.log(ret.installed);
                        }
                    });

                })


            } else {

                $("#encourage").hide();
                _modelStatus = false;
            }

        }, function (error) {

        })

    }

    //开启弹窗
    function openModel() {
        checkSystemType(function () {
            //ios
            var url = 'https://itunes.apple.com/cn/app/id1477929674';
            openURLInApp(url)

            // var mMarket = api.require('mMarket');
            // var param = {
            //     appid : '1477929674'
            // };
            // mMarket.iosShowComment(param);
        }, function () {
            if (_modelStatus && isDefine($("#encourageCon").html())) {
                _model.addClass('showModel');
                setTimeout(function () {
                    _model.find('.action-view').addClass('showView');
                }, 10)
            }else {
                pop.notice('暂未检测到相关应用市场，请下载相关应用市场再对我们鼓励',2.5)
            }


        })
    }

    //阻止事件冒泡
    function stopModel(event) {
        event.stopPropagation();
    }

    //关闭弹窗
    function closeModel(event) {
        if (event) {
            event.stopPropagation();
        }
        _model.find('.action-view').removeClass('showView');
        setTimeout(function () {
            _model.removeClass('showModel');
        }, 500)
    }


    //鼓励跳转
    function encourage(event, param) {
        event.stopPropagation();
        /*var mMarket = api.require('mMarket');
        var param = {
            pkg : 'com.binge.wt'   //应用的包名
        };
        mMarket.androidScore(param);*/
        var module = api.require('backmodule');
        module.back(param)
    }

    function qcChace() {
        clearCache();
        setTimeout(function () {
            getCacheSize(function (size) {
                $("#caCheSize").html(size);
            })
        }, 2500)

    }
</script>
